package com.zz.server.config;

import com.zz.common.config.Config;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
 * 服务器端配置
 *
 * @author zz
 */
@Slf4j
@Getter
public class TunnelServerConfig implements Serializable {

    private static final long serialVersionUID = 1L;


    /**
     * 代理服务器绑定主机host
     */
    private String serverBind;

    /**
     * 代理服务器与代理客户端通信端口
     */
    private Integer serverPort;

    /**
     * http 端口好
     */
    private Integer httpPort;

    private Integer httpsPort;


    @Getter
    private static TunnelServerConfig instance = new TunnelServerConfig();

    private TunnelServerConfig() {

        // 代理服务器主机和端口配置初始化
        this.serverPort = Config.getInstance().getIntValue("server.port");
        this.serverBind = Config.getInstance().getStringValue("server.bind", "0.0.0.0");

        // 配置服务器主机和端口配置初始化
        this.httpPort = Config.getInstance().getIntValue("server.http.port");
        this.httpsPort = Config.getInstance().getIntValue("server.https.port");
        log.info("config init serverBind {}, serverPort {}, httpPort {}, httpsPort {}",
                serverBind, serverPort, httpPort, httpsPort);

    }

    public List<Integer> getHttpPortList() {
        return Arrays.asList(httpPort);
    }

}
